import { Button, Typography } from "@mui/material";
import React, { useEffect } from "react";
import { useState } from "react";
import FindFail from "../../../components/FindFail";
import MyDialog from "../../../components/MyDialog";

export default function GetDetail(props) {
  const [open, setOpen] = useState(false);

  return (
    <div>
      <Button color="primary" onClick={() => setOpen(true)}>
        点击查看
      </Button>
      <MyDialog
        open={open}
        title="详细信息"
        onClose={() => {
          setOpen(false);
        }}
      >
        {props.value.dtype == 1 && (
        <>
          <Typography>
            课程号:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.courseId}</Typography>
          </Typography>
          <Typography>
            学分:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.credit}</Typography>
          </Typography>
          <Typography>
            课程容量:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.capacity}</Typography>
          </Typography>
          <Typography>
            上课地点:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.location}</Typography>
          </Typography>
        </>
        )}
        {props.value.dtype == 2 && (
          <>
            <Typography>
              课程号:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.courseId}</Typography>
            </Typography>
            <Typography>
              考试地点:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.area}</Typography>
            </Typography>
            <Typography>
              考试日期:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.date}</Typography>
            </Typography>
            <Typography>
              考试开始时间:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.betime}</Typography>
            </Typography>
            <Typography>
              考试结束时间:<Typography variant="body1" color="primary" component="span" sx={{marginLeft: 1}}>{props.value.endtime}</Typography>
            </Typography>
          </>
        )}
      </MyDialog>
    </div>
  );
}
